package com.frxuexi.park2302.my

import com.frxuexi.lib_base.http.ApiService
import com.frxuexi.lib_base.mvi.BaseViewModel
import com.frxuexi.lib_base.mvi.RequestType
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class MyViewModel @Inject constructor(val apiService: ApiService):BaseViewModel<MyIntent>(){
    override fun handlerIntent(it: MyIntent) {
        when(it){
            is MyIntent.getMyPark->httpRequest(apiService.getParkByUid(it.uid))
            is MyIntent.getMyVisit->httpRequest(apiService.getVisitByName(it.uname),RequestType.MYVISIT)
            is MyIntent.getMyRepair->httpRequest(apiService.getRepairByUser(it.uname),RequestType.MYREPAIR)
            is MyIntent.getMyPatrol->httpRequest(apiService.getPatrolByUser(it.uid),RequestType.MYPATROL)

            is MyIntent.getParks->httpRequest(apiService.getParkByType(it.type))
            is MyIntent.getVisits->httpRequest(apiService.getVisits(),RequestType.MYVISIT)
            is MyIntent.getNews->httpRequest(apiService.getNews(),RequestType.NEWS)
            is MyIntent.updateParkStatus->httpRequest(apiService.updateParkStatus(it.id,it.status),RequestType.UPDATE)
        }
    }
}